package com.h824;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class SetDemo {
    public static void main(String[] args) {
        Set set = new HashSet();
        set.add(123);
        set.add(324);
        set.add("abc");
        set.add("张");
        set.add(324);
        System.out.println(set);
        Object[] ocjs = set.toArray();
        for (int i = 0; i < ocjs.length; i++) {
            System.out.println(ocjs[i]);
        }
        System.out.println("==============");
        Set<String> names = new HashSet<>();
        names.add("王菲");
        names.add("谢霆锋");
        names.add("马越");
        //迭代器

        Iterator<String> it = names.iterator();
        while ((it.hasNext())){

            String n = it.next();
            System.out.println(n);
        }
        System.out.println("==============");

        for (String str:names){
            System.out.println(str);
        }


    }
}
